home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / CPlusIncludes / Connections.h < prev    next >
Text File  |  1991-05-01  |  7KB  |  269 lines

  1. /*
  2.     File:        Connections.h
  3.  
  4.     Contains:    C Interface to the Connection Manager
  5.  
  6.     Copyright:    © 1988-1990 by Apple Computer, Inc.
  7.                 All rights reserved.
  8.  
  9. */
  10.  
  11.  
  12. #ifndef    __CONNECTIONS__
  13. #define __CONNECTIONS__
  14.  
  15. #ifndef __DIALOGS__
  16. #include <Dialogs.h>
  17. #endif
  18.  
  19. #ifndef __GEOMETRY__
  20. #include <Geometry.h>
  21. #endif
  22.  
  23. #ifndef __CTBUTILITIES__
  24. #include <CTBUtilities.h>
  25. #endif
  26.  
  27. /*    current Connection Manager version    */
  28. #define    curCMVersion         2
  29.  
  30. /*    current Connection Manager Environment Record version     */
  31. #define    curConnEnvRecVers    0
  32.     
  33. /* CMErr */
  34. typedef    OSErr CMErr;
  35.  
  36. #define cmGenericError         (-1)
  37. #define    cmNoErr                0
  38. #define cmRejected            1
  39. #define cmFailed            2
  40. #define cmTimeOut            3
  41. #define cmNotOpen            4
  42. #define cmNotClosed            5
  43. #define cmNoRequestPending    6
  44. #define cmNotSupported         7
  45. #define cmNoTools            8    
  46. #define    cmUserCancel        9
  47. #define    cmUnknownError        11
  48.  
  49. /* CMRecFlags and CMChannel        */
  50. /*        Low word of CMRecFlags is same as CMChannel    */
  51. typedef long CMRecFlags;
  52. typedef short CMChannel;
  53.  
  54. enum {
  55.      cmData             = 1 << 0,
  56.     cmCntl             = 1 << 1,
  57.     cmAttn             = 1 << 2,
  58.     
  59.     cmDataNoTimeout    = 1 << 4,
  60.     cmCntlNoTimeout = 1 << 5,
  61.     cmAttnNoTimeout = 1 << 6,
  62.  
  63.     cmDataClean     = 1 << 8,        
  64.     cmCntlClean        = 1 << 9,
  65.     cmAttnClean        = 1 << 10,
  66.  
  67. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  68.     cmNoMenus         = 1 << 16,    
  69.     cmQuiet            = 1 << 17
  70. };
  71.  
  72. /*    connection status flags    */
  73. typedef long CMStatFlags;
  74.  
  75. enum {
  76.     cmStatusOpening        = 1 << 0,
  77.     cmStatusOpen         = 1 << 1,
  78.     cmStatusClosing     = 1 << 2,
  79.     cmStatusDataAvail     = 1 << 3,
  80.     cmStatusCntlAvail     = 1 << 4,
  81.     cmStatusAttnAvail     = 1 << 5,
  82.     
  83.     cmStatusDRPend         = 1 << 6,        /* data read pending    */
  84.     cmStatusDWPend         = 1 << 7,        /* data write pending    */
  85.     cmStatusCRPend         = 1 << 8,        /* cntl read pending    */
  86.     cmStatusCWPend         = 1 << 9,        /* cntl write pending    */
  87.     cmStatusARPend         = 1 << 10,        /* attn read pending    */
  88.     cmStatusAWPend         = 1 << 11,        /* attn write pending    */
  89.  
  90.     cmStatusBreakPend     = 1 << 12,
  91.     cmStatusListenPend     = 1 << 13,
  92.     cmStatusIncomingCallPresent 
  93.                         = 1 << 14,
  94.  
  95.     cmStatusReserved0    = 1 << 15
  96. };
  97.  
  98. /*    CMBuffers    fields    */
  99. typedef short CMBufFields;
  100.  
  101. enum {
  102.     cmDataIn,
  103.     cmDataOut,
  104.     
  105.     cmCntlIn,
  106.     cmCntlOut,
  107.     
  108.     cmAttnIn,
  109.     cmAttnOut,
  110.     
  111.     cmRsrvIn,
  112.     cmRsrvOut
  113. };
  114.  
  115. typedef Ptr CMBuffers[8];
  116. typedef long CMBufferSizes[8];
  117.  
  118. /*    CMSearchFlags    */
  119. typedef short CMSearchFlags;
  120.  
  121. enum {
  122.     cmSearchSevenBit =    1 << 0
  123. };
  124.  
  125. /*    CMFlags (CMRead/Write deliminator flags)    */
  126. typedef short CMFlags;
  127. enum {
  128.     cmFlagsEOM        =    1 << 0
  129. };
  130.  
  131. struct ConnEnvironRec {
  132.     short        version;
  133.     long        baudRate;
  134.     short        dataBits;
  135.     CMChannel    channels;
  136.     Boolean        swFlowControl;
  137.     Boolean        hwFlowControl;
  138.     CMFlags        flags;
  139. };
  140. typedef struct ConnEnvironRec ConnEnvironRec;
  141.  
  142. typedef ConnEnvironRec *ConnEnvironRecPtr;
  143.  
  144.  
  145. struct ConnRecord {
  146.     short        procID;
  147.     
  148.     CMRecFlags    flags;
  149.     CMErr        errCode;
  150.     
  151.     long        refCon;
  152.     long        userData;
  153.     
  154.     ProcPtr        defProc;
  155.     
  156.     Ptr            config;
  157.     Ptr            oldConfig;
  158.     
  159.     long        asyncEOM;
  160.     
  161.     long        reserved1;
  162.     long        reserved2;
  163.  
  164.     Ptr            cmPrivate;
  165.  
  166.     CMBuffers        bufferArray;
  167.     CMBufferSizes    bufSizes;
  168.  
  169.     long        mluField;
  170.     
  171.     CMBufferSizes    asyncCount;
  172. };
  173.  
  174. typedef struct ConnRecord ConnRecord;
  175. typedef ConnRecord *ConnPtr, **ConnHandle;
  176.  
  177.  
  178. #ifdef __cplusplus
  179. extern "C" {
  180. #endif    
  181. pascal CMErr        InitCM(void);
  182. pascal Handle     CMGetVersion(ConnHandle hConn);
  183. pascal short     CMGetCMVersion(void);
  184.  
  185. pascal ConnHandle    CMNew(short procID, CMRecFlags flags, const CMBufferSizes desiredSizes, 
  186.                                 long refCon, long userData);
  187.  
  188. pascal void         CMDispose(ConnHandle hConn);
  189.  
  190. pascal CMErr     CMListen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  191. pascal CMErr     CMAccept(ConnHandle hConn, Boolean accept);
  192.  
  193. pascal CMErr     CMOpen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  194. pascal CMErr     CMClose(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout, Boolean now);
  195.  
  196. pascal CMErr     CMAbort(ConnHandle hConn);
  197.  
  198. pascal void         CMIdle(ConnHandle hConn);
  199. pascal CMErr     CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags& flags);
  200.  
  201. pascal void         CMReset(ConnHandle hConn);
  202.  
  203. pascal void         CMBreak(ConnHandle hConn, long duration, Boolean async, 
  204.                             ProcPtr completor);
  205.  
  206. pascal CMErr     CMRead(ConnHandle hConn, Ptr theBuffer, long& toRead, 
  207.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  208.                             CMFlags& flags);
  209.  
  210. pascal CMErr     CMWrite(ConnHandle hConn, Ptr theBuffer, long& toWrite,
  211.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  212.                             CMFlags flags);
  213.  
  214. pascal CMErr     CMIOKill(ConnHandle hConn, short which);
  215.  
  216. pascal void         CMActivate(ConnHandle hConn, Boolean activate);
  217. pascal void         CMResume(ConnHandle hConn, Boolean resume);
  218. pascal Boolean     CMMenu(ConnHandle hConn, short menuID, short item);
  219.  
  220. pascal Boolean     CMValidate(ConnHandle hConn);
  221. pascal void         CMDefault(Ptr& theConfig, short procID, Boolean allocate);
  222.  
  223. pascal Handle     CMSetupPreflight(short procID, long& magicCookie);
  224. pascal Boolean     CMSetupFilter(short procID, Ptr theConfig, short count, 
  225.                             DialogPtr theDialog, EventRecord& theEvent, short& theItem, 
  226.                             long& magicCookie);
  227. pascal void         CMSetupSetup(short procID, Ptr theConfig, short count, 
  228.                             DialogPtr theDialog, long& magicCookie);
  229. pascal void         CMSetupItem(short procID, Ptr theConfig, short count, 
  230.                             DialogPtr theDialog, short& theItem, long& magicCookie);
  231. pascal void         CMSetupCleanup(short procID, Ptr theConfig, short count, 
  232.                             DialogPtr theDialog, long& magicCookie);
  233. pascal void         CMSetupPostflight(short procID);
  234.  
  235. pascal Ptr         CMGetConfig(ConnHandle hConn);
  236. pascal short     CMSetConfig(ConnHandle hConn, Ptr thePtr);
  237.  
  238. pascal OSErr     CMIntlToEnglish(ConnHandle hConn, 
  239.                             Ptr inputPtr, Ptr& outputPtr, short language);
  240. pascal OSErr     CMEnglishToIntl(ConnHandle hConn, 
  241.                             Ptr inputPtr, Ptr& outputPtr, short language);
  242.  
  243. pascal long         CMAddSearch(ConnHandle hConn, const Str255& theString, 
  244.                             CMSearchFlags flags, ProcPtr callBack);
  245. pascal void        CMRemoveSearch(ConnHandle hConn, long refnum);
  246. pascal void        CMClearSearch(ConnHandle hConn);
  247.  
  248. pascal CMErr     CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec& theEnvirons);
  249.         
  250. pascal short     CMChoose(ConnHandle& hConn, Point where, ProcPtr idleProc);
  251.  
  252. pascal void        CMEvent(ConnHandle hConn, const EventRecord& theEvent);
  253.  
  254. pascal void         CMGetToolName(short procID, Str255& name);
  255. pascal short     CMGetProcID(const Str255& name);
  256.  
  257. pascal void        CMSetRefCon(ConnHandle hConn, long refCon);
  258. pascal long         CMGetRefCon(ConnHandle hConn);
  259.  
  260. pascal long         CMGetUserData(ConnHandle hConn);
  261. pascal void         CMSetUserData(ConnHandle hConn, long userData);
  262.  
  263.  
  264.  
  265. #ifdef __cplusplus
  266. }
  267. #endif
  268.  
  269. #endif __CONNECTIONS__